﻿using System;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PodcastGenerator;
using Rhino.Mocks;

namespace PodcastGeneratorTests
{
    [TestClass]
    public class SermonDownloaderTest
    {
        private ISermon _sermon;
        private ISermonDownloader _sermonDownloader;
        [TestInitialize]
        public void Init()
        {
            _sermonDownloader = new SermonDownloader(".");
            _sermon = MockRepository.GenerateMock<ISermon>();
            _sermon.Stub(p => p.DownloadUri).Return(new Uri(Path.GetFullPath("TestPage\\20130106am.mp3")));
            _sermon.Stub(p => p.Date).Return(DateTime.Now);
            _sermon.Stub(p => p.Pastor).Return("The Boss");
            _sermon.Stub(p => p.Title).Return("How to train a dragon");
        }

        [TestMethod]
        [ExpectedException(typeof(DirectoryNotFoundException))]
        public void ThrowsExceptionOnInvalidStoreLocation()
        {
            var bogusSermonDownloader = new SermonDownloader("f:\\bogus");
        }

        [TestMethod]
        public void CanDownloadUri()
        {
            var downloadedOk = _sermonDownloader.Download(_sermon);
            Assert.IsTrue(downloadedOk);
        }
    }

    
}